const http = require('http')
http.createServer((req, res) => {
  const urll = new URL(req.url, 'http://localhost:3000/')
  console.log(urll.searchParams.get('callback'))
  const obj = {
    name: 'zp',
    age: 100
  }
  res.writeHead(200, {
    "Cpntent-Type": "application/json;charset=utf-8",
    "access-control-allow-origin": '*'
  })
  console.log(urll.pathname)
  switch (urll.pathname) {
    case '/data':
      res.end(JSON.stringify(obj))
      break;

    default:
      res.end('404')
  }
}).listen(3000, () => console.log('创建成功！'))